home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / bsrc_p1.arc / FOSSIL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-30  |  5.9 KB  |  223 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software <no-Inc>                   */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          No-Cost<no-tm> Software.                       */
  7. /*        \ 1011 /                                                          */
  8. /*         ------            KopyRong (K) 1987.  ALL RIGHTS REVERSED.       */
  9. /*                                                                          */
  10. /*                                                                          */
  11. /*           This module was originally written by Bob Hartman              */
  12. /*                                                                          */
  13. /*                                                                          */
  14. /*                 BinkleyTerm FOSSIL version 5 module                      */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*   This  software  package is being distributed WITH FULL SOURCE CODE     */
  18. /*   with the  following  conditions:    1)  If  anything awful happens     */
  19. /*   because  you  use    it   (or  don't  use  it),  you  accept  full     */
  20. /*   responsibility;  2) you  don't start making tons of voice calls to     */
  21. /*   the authors to complain or  make  suggestions  about enhancements,     */
  22. /*   useful or otherwise;  3) you  do not reuse this code in commercial     */
  23. /*   products without specific permission to do so  from  the  authors;     */
  24. /*   4) If you find any problems you send  fixes  to  the  authors  for     */
  25. /*   inclusion  in  updates;    5) You find some way  to  express  your     */
  26. /*   appreciation  for  this  method of distribution, either by writing     */
  27. /*   code or  application  notes,  or  just sending along a "Thank You"     */
  28. /*   message.                                                               */
  29. /*                                                                          */
  30. /*   There is  copyrighted  code  in  this product.  We either wrote it     */
  31. /*   ourselves or got  permission  to use it.  Please don't force us to     */
  32. /*   pay a lawyer --  have some respect for our motives and don't abuse     */
  33. /*   this "license".                                                        */
  34. /*                                                                          */
  35. /*                                                                          */
  36. /*--------------------------------------------------------------------------*/
  37.  
  38. #include <dos.h>
  39. #include "opus.h"
  40. #include "com.h"
  41.  
  42. static char my_buffer[128];
  43. static char *my_pointer = my_buffer;
  44. static char *my_end = my_buffer;
  45. static int old_fossil = 1;
  46.  
  47. struct finfo {
  48.    int   info_size;
  49.    char  curr_fossil;
  50.    char  curr_rev;
  51.    char  far *id_string;
  52.    int   ibufr;
  53.    int   ifree;
  54.    int   obufr;
  55.    int   ofree;
  56.    int   swidth;
  57.    int   sheight;
  58.    char  baud;
  59. } fossil_info = {
  60.    0, 0, 0, 0L, 0, 0, 0, 0, 0, 0, 0
  61. };
  62.  
  63. fill_buffer ()
  64. {
  65.    char far *pass;
  66.  
  67.    if (old_fossil)
  68.       {
  69.       ++my_end;
  70.       *my_pointer = Com_(0x02)&0x00ff;
  71.       }
  72.    else
  73.       {
  74.       pass = (char far *) my_pointer;
  75.       my_end += fossil_block (0x1800, pass, 127);
  76.       }
  77. }
  78.  
  79. unsigned MODEM_IN ()
  80. {
  81.    unsigned c;
  82.  
  83.    while (my_pointer == my_end)
  84.       {
  85.       /* Read a buffer full and bump pointer */
  86.       fill_buffer ();
  87.  
  88.       if (my_pointer == my_end)
  89.          time_release();
  90.       }
  91.  
  92.    c = *my_pointer++;
  93.    c &= 0x00ff;
  94.    if (my_pointer == my_end)
  95.       {
  96.       my_pointer = my_buffer;
  97.       my_end = my_buffer;
  98.       }
  99.  
  100.    return (c);
  101. }
  102.  
  103. unsigned PEEKBYTE ()
  104. {
  105.    unsigned c;
  106.  
  107.    if (my_pointer == my_end)
  108.       {
  109.       if (Com_(0x03)&DATA_READY)
  110.          {
  111.          fill_buffer ();
  112.          }
  113.       else
  114.          {
  115.          return (0xFFFF);
  116.          }
  117.       }
  118.  
  119.    c = *my_pointer;
  120.    c &= 0x00ff;
  121.    return (c);
  122. }
  123.  
  124. CLEAR_INBOUND ()
  125. {
  126.    my_pointer = my_buffer;
  127.    my_end = my_buffer;
  128.    Com_(0x0a);
  129. }
  130.  
  131. MODEM_STATUS ()
  132. {
  133.    unsigned int c;
  134.  
  135.    c = Com_(0x03);
  136.    if ((!(c & DATA_READY)) && (my_pointer != my_end))
  137.       c |= DATA_READY;
  138.    return (c);
  139. }
  140.  
  141. MDM_ENABLE (b)
  142. unsigned int b;
  143. {
  144.    my_pointer = my_end = my_buffer;
  145.    return (Com_(0x00,b|NO_PARITY|STOP_1|BITS_8));
  146. }
  147.  
  148. MDM_DISABLE ()
  149. {
  150.    my_pointer = my_end = my_buffer;
  151.    return (Com_(0x05,BAUD_2400|NO_PARITY|STOP_1|BITS_8));
  152. }
  153.  
  154. SENDBYTE (c)
  155. unsigned char c;
  156. {
  157.    while (Com_Tx_NW (c) == 0)
  158.       {
  159.       time_release();
  160.       }
  161. }
  162.  
  163. SENDCHARS (str, len, car)
  164. char *str;
  165. register int len;
  166. int car;
  167. {
  168.    register int i;
  169.    char far *p;
  170.  
  171.    if (old_fossil)
  172.       {
  173.       for (; len > 0; --len)
  174.          {
  175.          if (car && !CARRIER)
  176.             return;
  177.          SENDBYTE (*str++);
  178.          }
  179.       }
  180.    else
  181.       {
  182.       i = 0;
  183.       for (; len > 0; len -= i)
  184.          {
  185.          p = (char far *) str;
  186.          i = fossil_block (0x1900, p, len);
  187.          if (i != len)
  188.             {
  189.             str += i;
  190.             time_release();
  191.             }
  192.          else if (car && !CARRIER)
  193.             return;
  194.          }
  195.       }
  196. }
  197.  
  198. Cominit (p)
  199. int p;
  200. {
  201.    my_pointer = my_end = my_buffer;
  202.    return (ComI(p));
  203. }
  204.  
  205. fossil_ver ()
  206. {
  207.    char far *q;
  208.  
  209.    q = (char far *) &fossil_info;
  210.    fossil_block (0x1b00, q, sizeof (struct finfo));
  211.  
  212.    if (fossil_info.curr_fossil > 0)
  213.       {
  214.       old_fossil = 0;
  215.       cprintf ("FOSSIL: %Fs\033[K\r\n", fossil_info.id_string);
  216.       }
  217.    else
  218.       {
  219.       cprintf ("FOSSIL: Revision Level 3 Assumed\033[K\r\n");
  220.       }
  221. }
  222.  
  223.